Container With Most Water
August 19, 2016
Start off with both ends and keep moving to the middle, while on every iteration checking the new max result.
Full Solution in Java:
/** public class Solution { public int maxArea(int[] height) { int left = 0; int right = height.length-1; int result = 0; while(left!=right){ int area = Math.min(height[left], height[right])*(right-left); result = Math.max(result, area); if(height[left]< height[right]){ left++; } else{ right--; } } return result; } }